﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Diagnostics;

public partial class OutSourcingEvaluacion : System.Web.UI.Page
{
    //creamos el dataset que contendra las tablas
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["iduser"] == null || Session["iduser"].ToString() == "0")
            {
                Response.Redirect("index.aspx");
            }
            else
            {
                                 //llenamos el dataset con los datos de la tablas de Outsourcing
                   Outs.Outsourcing O = new Outs.Outsourcing();
                   ds = O.ConsultaOutSourcing();
            }
        }
    }
        
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
        //creamos el objeto tabla para llenar una nueva fila
        DataTable TOut = ds.Tables["ExpEvaluacion"];
        DataRow row = TOut.NewRow();
        //ingrasamos los datos de la fila
        row["IdExpEvaluacion"] = ds.Tables["ExpEvaluacion"].Rows.Count + 1;
        row["Test"] = TxtOutEvaluacion.Text;
        row["Resultado"] =TxtOutResul.Text ;
        row["Observacion"] = TxtOutObservacion.Text;
         row["IdCandidato"] = 1;


        ds.Tables["ExpEvaluacion"].Rows.Add(row);

        Outs.Outsourcing cl = new Outs.Outsourcing();
        cl.DatoEvaluacion(ds);
        ds.AcceptChanges();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }

    
}